// 分页跳转
//页面跳转
function _goto(pageIndex) {
//	var _url = "dictionary/value_mgr/@.html".replace("@", pageIndex);
//	$("#query_form input[type='text']").val(function() {
//		return $.trim(this.value).replace(/[^-0-9a-zA-Z\u4E00-\u9FA5 ]/g,"");
//	});
//	
//	if($("#type").val()!='')
//	{
//		$("#type_id").val(encodeURI($("#type").val()));
//	}
//	$("#query_form").attr("action", _url);
//	$("#query_form").submit();
	
	$('#test').datagrid('load',{
		name:$('#name').val(),
		dbId:$('#dbId').val()
	});
	
}
/**
 * 表彰重置
 */
function formReset() {
	$("#query_form input[type='text']").val("");
	$("#query_form select").val("");
	$("#dbId").val("0");
}
// 界面初始化
function initView() {
	
}

function deleteDict(dbId) {
	var url = parent.formateUrl("dictionary/delete/@.json".replace("@", dbId));
	$.messager.confirm("删除字典","是否确认删除当前字典？",function (r){
		if(r)
		{
			
			
			$.ajax({
				type : "post",
				dataType : "json",
				url :url,
				success : function(data) {
					$.messager.show({
						title:'提示',
						msg:'删除成功',
						showType:'show',
						timeout:1000,
						style:{
							right:'',
							top:document.body.scrollTop+document.documentElement.scrollTop,
							bottom:''
						}
					});
					top.refresh('reloadList');
				},
				error : function() {
					$.messager.show({
						title:'提示',
						msg:data.msg.body,
						showType:'show',
						timeout:2000,
						style:{
							right:'',
							top:document.body.scrollTop+document.documentElement.scrollTop,
							bottom:''
						}
					});
				}
			});
		}
	})
	return 
	art.dialog.confirm("是否确定删除？", function() {
		var url = parent.formateUrl("dictionary/delete/@.json".replace("@", dbId));
		$.ajax({
			type : "post",
			dataType : "json",
			url : url,
			success : function(data) {
				art.dialog.tips("删除成功");
				window.setTimeout(function() {
					//window.parent.frames["ifrm_data"]._goto(pageIndex);
					top.refresh('reloadList');
					art.dialog.close();
				}, 1500);
			},
			error : function() {
				art.dialog.tips("删除失败");
			}
		});
	});
}

/**
 * 跳转到字典值新增
 */
function addDictionary() {
	var url = parent.formateUrl("dictionary/gotoadd.html");
	var options = {
			w:400,h:230,title:"字典值新增",fn:'submitForm',id:"dict"
	}
	top.showWin(url,options)
	return ;
	var url = parent.formateUrl("dictionary/gotoadd.html");
	win = art.dialog.open(url, {
		title : "字典值新增",
		lock : true,
		width : 400,
		height : 150,
		fixed : true,
		ok : function() {
			var iframe = this.iframe.contentWindow;
			if (!iframe.document.body) {
				art.dialog.tips("正在加载，请稍候...", 1500);
				return false;
			}
			iframe.submitForm();
			return false;
		},
		cancel : true
	});
}

/**
 * 跳转到字典值编辑
 */
function editDictionary(dbId) {
	
	var url = parent.formateUrl("dictionary/gotoedit/@.html".replace("@", dbId));
	var options = {
			w:400,h:230,title:"字典值修改",fn:'submitForm',id:"dict"
	}
	top.showWin(url,options)
	return 
	var url = parent.formateUrl("dictionary/gotoedit/@.html".replace("@", dbId));
	win = art.dialog.open(url, {
		title : "字典值编辑",
		lock : true,
		width : 400,
		height : 150,
		fixed : true,
		ok : function() {
			var iframe = this.iframe.contentWindow;
			if (!iframe.document.body) {
				art.dialog.tips("正在加载，请稍候...", 1500);
				return false;
			}
			iframe.submitForm();
			return false;
		},
		cancel : true
	});
}


//刷新数据列表
function reloadList(){
	
	$('#test').datagrid('reload');
}


function afterSave()
{
	window.setTimeout(function() {
		//先关闭窗口
		top.closeWin('dict');
		reloadList();
		top.unmask();
	}, 1500);	
}
